package jisuanji;

import java.awt.geom.Arc2D;
import java.awt.Shape;

public class Sector extends MyShape {
    private double r, angleDeg;
    
    public Sector(double r, double angleDeg) {
        super("扇形");
        this.r = r;
        this.angleDeg = Math.abs(angleDeg % 360);
    }
    
    @Override
    public double getArea() {
        return Math.PI * r * r * angleDeg / 360.0;
    }
    
    @Override
    public double getPerimeter() {
        double arc = 2 * Math.PI * r * angleDeg / 360.0;
        return arc + 2 * r;
    }
    
    @Override
    public Shape getRealShape() {
        return new Arc2D.Double(-r, -r, 2 * r, 2 * r, 0, angleDeg, Arc2D.PIE);
    }
}